package org.nanotek.persistence.jpa.base;

import java.util.List;

import javax.validation.constraints.NotNull;

import org.nanotek.base.StringBase;
import org.nanotek.persistence.jpa.BrainzBaseDAO;

public class StringBaseDAO<T extends StringBase> extends BrainzBaseDAO<T> {
	
	@SuppressWarnings("unchecked")
	public List<T> findValue (@NotNull String value) 
	{ 
		
//		Metamodel metaModel = entityManager.getMetamodel();
//		CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
//		//Fix to Pick Generic Type.
//		CriteriaQuery<StringBase> criteriaQuery = criteriaBuilder.createQuery(getBaseClass());
//		criteriaQuery.select(criteriaQuery.from(getBaseClass()));
////		Root<StringBase> rootBase = criteriaQuery.from(getBaseClass());
//////		CriteriaQuery<getGenericType()> criteriaQuery = criteriaBuilder.createQuery(getBaseClass());
////		criteriaQuery.select(criteriaQuery.from(getBaseClass()));
////		TypedQuery<StringBase> typedQuery = entityManager.createQuery(criteriaQuery.select(criteriaQuery.from(getBaseClass())));
//////		criteriaBuilder.createQuery();
		return 	entityManager.createQuery("Select c from org.nanotek.base.StringBase c where c.value like concat('%',concat(:value,'%'))").setParameter("value", value).getResultList();
	}
	
}
